package com.toune.blackmusic.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.toune.blackmusic.R;
import com.toune.blackmusic.database.MusicVo;
import com.toune.blackmusic.util.MyUtil;
import com.vondear.rxui.view.RxTextViewVertical;

import java.util.ArrayList;
import java.util.List;

public class AdapterMusicVo extends BaseQuickAdapter<MusicVo.DataBean, BaseViewHolder> {

    public AdapterMusicVo(int layoutResId, @Nullable List<MusicVo.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final MusicVo.DataBean item) {
        ImageView imageView = helper.getView(R.id.cover_iv);
        Glide.with(mContext).load(item.getPic()).apply(new RequestOptions().centerCrop().placeholder(R.drawable.music_note).error(R.drawable.music_note)).into(imageView);
        RelativeLayout relativeLayout = helper.getView(R.id.play_rl);
        helper.setText(R.id.title_tv, "歌名：" + item.getTitle());
        helper.setText(R.id.author_tv, "作者：" + item.getAuthor());
        helper.getView(R.id.down_mp3_btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MyUtil.DownMusic(mContext, item);
            }
        });
    }
}
